/* JavaLog - pkg tracker 
 * 
 * Copyright (C) 2009 Allyson Lima, Diego Pedro, Victor Freire
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software 
 * Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this 
 * program. If not, see <http://www.gnu.org/licenses/>.
 */

package br.edu.ufcg.ccc.javalog.model;

import br.edu.ufcg.ccc.javalog.exceptions.PackageException;

/**
 * A express Package
 * 
 * @author Allyson Lima, Diego Pedro, Victor Freire
 * @version 03/12/09
 */
public class PackageExpress extends Package {

	/**
	 * Static final attribute for type package
	 */
	private final static String type = "Expressa";

	/**
	 * Constructor default
	 * 
	 * @param senderAddress
	 *            Address of the sender
	 * @param recipientAddress
	 *            Address of the recipient
	 * @param sourceFranchise
	 *            Source Franchise
	 * @param destinationFranchise
	 *            Destination Franchise
	 * @throws PackageException
	 *             Invalid arguments
	 */
	public PackageExpress(Address senderAddress, Address recipientAddress,
			Franchise sourceFranchise, Franchise destinationFranchise)
			throws PackageException {
		super(senderAddress, recipientAddress, sourceFranchise,
				destinationFranchise);
	}

	/**
	 * Returns the type of the package
	 * 
	 * @return the type of the package
	 */
	@Override
	public String getType() {
		return type;
	}
	
	/**
	 * Moves this package to the next franchise following the normal mode
	 */
	@Override
	public void move() throws PackageException {
		if (getCurrentFranchise() == getDestinationFranchise())
			throw new PackageException(
					"move() should not be called! the package is already at the destination");
		Franchise nextFranchise = getSourceFranchise()
				.getNextFranchiseInShortestPath(getDestinationFranchise());
		setCurrentFranchise(nextFranchise);
		// TODO Update package tracking report
		nextFranchise.receivePackage(this);

	}

//	@Override
//	public String toString() {
//		return type;
//	}
}
